<template>
	<view class="">
		<div class="notice">
			<uni-notice-bar scrollable showIcon :text="notice"></uni-notice-bar>
		</div>
		<yyyddyyd-freetimetables @clickkbdata="clickkb" :kbjsheight="kbjsheight" :kbJs="kbJs"
			:nowweekclass="nowweekclass" :hqxq="hqxq" :kbList="kbList">
			<template #popup>
				<view class="">
					<view style="display: flex;justify-content: center;align-items: center;">
						<button type="primary" size="mini" style="margin-bottom: 50px;"
							@click="addkblist">教务系统导入</button>
						<button type="primary" size="mini" style="margin-bottom: 50px;" @click="upics">导入日程</button>
					</view>
				</view>
			</template>
		</yyyddyyd-freetimetables>
		<view v-show="pickerxs">
			<uni-data-picker ref="picker" :ellipsis="false" placeholder="请选择班级" popup-title="请选择当前学期"
				:localdata="localdata" v-model="classes" @change="onchange" @popupclosed="onpopupclosed">
			</uni-data-picker>
		</view>
	</view>
</template>

<script setup>
	import {
		ref,
		reactive,
		onMounted,
		onUpdated
	} from 'vue';
	// 这里假设这两个广告相关的变量在Vue 3中也有对应的合适处理方式，示例中暂未详细体现其完整逻辑变更，仅保留基本定义形式
	const interstitialAd = null;
	const rewardedVideoAd = null;
	
	const notice = ref("通知，明天起，放假三天，三天后继续放假！")

	// 使用ref和reactive来定义响应式数据
	const hqxq = ref('大一第一学期');
	const keyword = ref("");
	const xnxq = ref([]);
	const pickerxs = ref(false);
	const classes = ref('2018');
	const localdata = reactive([{
		text: "2018-2019",
		value: "2018",
		children: [{
				text: "第一学期",
				value: "2018-3"
			},
			{
				text: "第二学期",
				value: "2018-12"
			}
		]
	}, {
		text: "2019-2020",
		value: "2019",
		children: [{
				text: "第一学期",
				value: "2019-3"
			},
			{
				text: "第二学期",
				value: "2019-12"
			}
		]
	}, {
		text: "2020-2021",
		value: "2020",
		children: [{
				text: "第一学期",
				value: "2020-3"
			},
			{
				text: "第二学期",
				value: "2020-12"
			}
		]
	}, {
		text: "2021-2022",
		value: "2021",
		children: [{
				text: "第一学期",
				value: "2021-3"
			},
			{
				text: "第二学期",
				value: "2021-12"
			}
		]
	}, {
		text: "2022-2023",
		value: "2022",
		children: [{
				text: "第一学期",
				value: "2022-3"
			},
			{
				text: "第二学期",
				value: "2022-12"
			}
		]
	}, {
		text: "2023-2024",
		value: "2023",
		children: [{
				text: "第一学期",
				value: "2023-3"
			},
			{
				text: "第二学期",
				value: "2023-12"
			}
		]
	}, {
		text: "2024-2025",
		value: "2024",
		children: [{
				text: "第一学期",
				value: "2024-3"
			},
			{
				text: "第二学期",
				value: "2024-12"
			}
		]
	}, {
		text: "2025-2026",
		value: "2025",
		children: [{
				text: "第一学期",
				value: "2025-3"
			},
			{
				text: "第二学期",
				value: "2025-12"
			}
		]
	}, {
		text: "2026-2027",
		value: "2026",
		children: [{
				text: "第一学期",
				value: "2026-3"
			},
			{
				text: "第二学期",
				value: "2026-12"
			}
		]
	}]);
	const kbjsheight = ref(78);

	const kbJs = ref([{
		kssj: '08:00',
		jssj: '08:50',
		style: 'background-color: #FF7F50;'
	}, {
		kssj: '09:00',
		jssj: '09:50',
		style: 'background-color:#FFE4E1;'
	}, {
		kssj: '10:10',
		jssj: '11:00',
		style: 'background-color: #FF7F50;'
	}, {
		kssj: '11:10',
		jssj: '11:50',
		style: 'background-color:#FFE4E1;'
	}, {
		kssj: '14:00',
		jssj: '14:50',
		style: 'background-color: #FF7F50;'
	}, {
		kssj: '15:00',
		jssj: '15:50',
		style: 'background-color:#FFE4E1;'
	}, {
		kssj: '16:10',
		jssj: '17:00',
		style: 'background-color: #FF7F50;'
	}, {
		kssj: '17:10',
		jssj: '17:50',
		style: 'background-color:#FFE4E1;'
	}, {
		kssj: '19:00',
		jssj: '19:50',
		style: 'background-color: #FF7F50;'
	}, {
		kssj: '20:00',
		jssj: '20:50',
		style: 'background-color:#FFE4E1;'
	}]);

	const kbList = ref([{
		"kcmc": "高等数学",
		"kcxz": "必修",
		"color": "#000000",
		"jsxx": "陈九",
		"kbData": [{
			"jxdd": "教室103",
			"week": 0,
			"jc": [1, 2],
			"jxz": [2, 4, 5, 7, 8, 13, 14, 15]
		}]
	}, {
		"kcmc": "高等数学",
		"kcxz": "必修",
		"color": "#000000",
		"jsxx": "陈九",
		"kbData": [{
			"jxdd": "教室103",
			"week": 1,
			"jc": [1, 2],
			"jxz": [2, 4, 5, 7, 8, 13, 14, 15]
		}]
	}, {
		"kcmc": "大学体育",
		"kcxz": "必修",
		"jsxx": "王五",
		"kbData": [{
			"jxdd": "田径场",
			"week": 1,
			"jc": [1, 4],
			"jxz": [9, 10, 11, 12]
		}]
	}, {
		"kcmc": "流体力学",
		"kcxz": "必修",
		"color": "#0000ff",
		"jsxx": "程八",
		"kbData": [{
			"jxdd": "教室103",
			"week": 1,
			"jc": [3, 4],
			"jxz": [2, 4, 5, 7, 8, 13, 14, 15, 16, 17]
		}]
	}, {
		"kcmc": "流体力学",
		"kcxz": "必修",
		"jsxx": "程八",
		"kbData": [{
			"jxdd": "语音实验室1",
			"week": 1,
			"jc": [5, 8],
			"jxz": [14]
		}]
	}, {
		"kcmc": "电工电子技术",
		"kcxz": "必修",
		"jsxx": "周十四",
		"kbData": [{
			"jxdd": "电工电子实验室",
			"week": 1,
			"jc": [5, 8],
			"jxz": [17]
		}]
	}, {
		"kcmc": "有机化学",
		"kcxz": "必修",
		"jsxx": "赵一",
		"kbData": [{
			"jxdd": "教室103",
			"week": 2,
			"jc": [1, 2],
			"jxz": [2, 3, 4, 5, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]
		}]
	}, {
		"kcmc": "电工电子技术",
		"kcxz": "必修",
		"jsxx": "钱二",
		"kbData": [{
			"jxdd": "教室305",
			"week": 2,
			"jc": [3, 4],
			"jxz": [2, 3, 4, 5, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]
		}]
	}, {
		"kcmc": "大学英语",
		"kcxz": "必修",
		"jsxx": "张三",
		"kbData": [{
			"jxdd": "教室103",
			"week": 2,
			"jc": [5, 6],
			"jxz": [8, 13, 14, 15, 16, 17]
		}]
	}, {
		"kcmc": "电工电子技术",
		"kcxz": "必修",
		"jsxx": "周十三",
		"kbData": [{
			"jxdd": "未排地点",
			"week": 2,
			"jc": [5, 8],
			"jxz": [9]
		}]
	}, {
		"kcmc": "有机化学",
		"kcxz": "必修",
		"jsxx": "努娜",
		"kbData": [{
			"jxdd": "有机化学实验室1",
			"week": 2,
			"jc": [5, 8],
			"jxz": [11, 12]
		}]
	}, {
		"kcmc": "国家安全教育",
		"kcxz": "必修",
		"jsxx": "周十二",
		"kbData": [{
			"jxdd": "五教201",
			"week": 2,
			"jc": [7, 8],
			"jxz": [3]
		}]
	}, {
		"kcmc": "无机化学",
		"kcxz": "任选",
		"jsxx": "周十一",
		"kbData": [{
			"jxdd": "教室107",
			"week": 2,
			"jc": [9, 10],
			"jxz": [2, 3, 4, 5, 7, 8, 9, 10, 11, 12, 13, 14]
		}]
	}, {
		"kcmc": "马克思主义基本原理概论",
		"kcxz": "必修",
		"jsxx": "刘六",
		"kbData": [{
			"jxdd": "教室103",
			"week": 3,
			"jc": [1, 2],
			"jxz": [2, 3, 4, 5, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]
		}]
	}, {
		"kcmc": "大学语文",
		"kcxz": "必修",
		"jsxx": "李四",
		"kbData": [{
			"jxdd": "教室103",
			"week": 3,
			"jc": [3, 4],
			"jxz": [2, 3, 4, 5, 7, 8, 9, 10, 11, 12, 13, 14, 16]
		}]
	}, {
		"kcmc": "电工电子技术",
		"kcxz": "必修",
		"jsxx": "钱二",
		"kbData": [{
			"jxdd": "教室103",
			"week": 3,
			"jc": [3, 4],
			"jxz": [15, 17]
		}]
	}, {
		"kcmc": "大学英语",
		"kcxz": "必修",
		"jsxx": "张三",
		"kbData": [{
			"jxdd": "教室103",
			"week": 4,
			"jc": [1, 2],
			"jxz": [2, 3, 4, 5, 7, 8, 9, 10, 13, 14, 15, 16, 17]
		}]
	}, {
		"kcmc": "高等数学",
		"kcxz": "必修",
		"jsxx": "陈九",
		"kbData": [{
			"jxdd": "未排地点",
			"week": 4,
			"jc": [1, 4],
			"jxz": [11, 12]
		}]
	}, {
		"kcmc": "流体力学",
		"kcxz": "必修",
		"jsxx": "程八",
		"kbData": [{
			"jxdd": "教室103",
			"week": 4,
			"jc": [3, 4],
			"jxz": [2, 3, 4, 5, 7, 8, 9, 10, 13, 14, 15, 16]
		}]
	}, {
		"kcmc": "大学语文",
		"kcxz": "必修",
		"jsxx": "李四",
		"kbData": [{
			"jxdd": "教室103",
			"week": 4,
			"jc": [5, 6],
			"jxz": [2, 3, 4, 5, 7, 11]
		}]
	}, {
		"kcmc": "高等数学",
		"kcxz": "必修",
		"jsxx": "陈九",
		"kbData": [{
			"jxdd": "教室103",
			"week": 4,
			"jc": [5, 6],
			"jxz": [8, 9, 10, 12]
		}]
	}, {
		"kcmc": "电工电子技术",
		"kcxz": "必修",
		"jsxx": "钱二",
		"kbData": [{
			"jxdd": "教室103",
			"week": 4,
			"jc": [5, 6],
			"jxz": [14, 16]
		}]
	}, {
		"kcmc": "马克思主义基本原理概论",
		"kcxz": "必修",
		"jsxx": "刘六",
		"kbData": [{
			"jxdd": "教室103",
			"week": 4,
			"jc": [7, 8],
			"jxz": [2, 3, 4, 5, 7, 8, 9, 10, 11]
		}]
	}, {
		"kcmc": "有机化学",
		"kcxz": "必修",
		"jsxx": "赵一",
		"kbData": [{
			"jxdd": "教室103",
			"week": 5,
			"jc": [1, 2],
			"jxz": [2, 3, 4, 5, 7]
		}]
	}, {
		"kcmc": "大学体育",
		"kcxz": "必修",
		"jsxx": "王五",
		"kbData": [{
			"jxdd": "田径场",
			"week": 5,
			"jc": [1, 4],
			"jxz": [9, 10, 11, 12, 13]
		}]
	}, {
		"kcmc": "大学语文",
		"kcxz": "必修",
		"jsxx": "李四",
		"kbData": [{
			"jxdd": "学院实训基地",
			"week": 5,
			"jc": [1, 4],
			"jxz": [14, 16]
		}]
	}, {
		"kcmc": "工程机械基础",
		"kcxz": "任选",
		"jsxx": "孙三",
		"kbData": [{
			"jxdd": "教室107",
			"week": 6,
			"jc": [1, 2],
			"jxz": [3, 4, 5, 7, 8, 9, 10, 11, 12, 13, 14, 15]
		}]
	}, {
		"kcmc": "大学语文",
		"kcxz": "必修",
		"jsxx": "李四",
		"kbData": [{
			"jxdd": "教室103",
			"week": 6,
			"jc": [5, 6],
			"jxz": [6]
		}]
	}, {
		"kcmc": "电工电子技术",
		"kcxz": "必修",
		"jsxx": "钱二",
		"kbData": [{
			"jxdd": "教室103",
			"week": 0,
			"jc": [1, 2],
			"jxz": [6]
		}]
	}, {
		"kcmc": "大学英语",
		"kcxz": "必修",
		"jsxx": "张三",
		"kbData": [{
			"jxdd": "教室103",
			"week": 0,
			"jc": [3, 4],
			"jxz": [6]
		}]
	}]);



	const nowjxweek = ref(1);
	const nowweekclass = ref('background-color: #00FF00;');
	const items = ref([]);
	const xueyuan_login = ref({});

	// 模拟原来的onLoad生命周期钩子逻辑
	onMounted(() => {
		const xueyuan_Timetable = uni.getStorageSync('xueyuan_Timetable');
		if (xueyuan_Timetable) {
			kbList.value = xueyuan_Timetable.kbList;
			hqxq.value = xueyuan_Timetable.hqxq;
		}
	});

	// 模拟原来的onShow生命周期钩子（这里为空，可根据实际需求补充逻辑）
	onUpdated(() => {});

	const clickkb = (res) => {
		console.log(res);
	};

	const onpopupclosed = (e) => {
		pickerxs.value = false;
	};

	const onchange = (e) => {};

	const addkblist = () => {
		console.log('请自己实现');
	};

	const upics = () => {
		console.log('请自己实现');
	};
</script>

<style lang="scss">
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.text-area {
		display: flex;
		justify-content: center;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}

	.wrap {
		padding: 24rpx;
	}

	.u-row {
		margin: 40rpx 0;
	}

	.demo-layout {
		height: 80rpx;
		border-radius: 8rpx;
	}

	.bg-purple {
		background: #d3dce6;
	}

	.bg-purple-light {
		background: #e5e9f2;
	}

	.bg-purple-dark {
		background: #99a9bf;
	}
</style>